package com.lantosec.hmrp.modules.system.entity;

import java.util.Date;

import com.lantosec.hmrp.core.mvc.BaseEntity;
import com.lantosec.hmrp.modules.system.vo.SysLogVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;

/**
 * <p>
 * 系统日志表 实体类
 * </p>
 *
 * @author AutoCode
 * @since 2020-07-03
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysLog extends BaseEntity<SysLogVO> {

    private static final long serialVersionUID = 1L;
    public SysLog(SysLogVO vo){
        this.id = vo.getId();
        this.userId = vo.getUserId();
        this.logName = vo.getLogName();
        this.logType = vo.getLogType();
        this.uri = vo.getUri();
        this.url = vo.getUrl();
        this.httpMethod = vo.getHttpMethod();
        this.ip = vo.getIp();
        this.parameter = vo.getParameter();
        this.result = vo.getResult();
        this.classMethod = vo.getClassMethod();
        this.userAgent = vo.getUserAgent();
        this.takeTime = vo.getTakeTime();
        this.createTime = vo.getCreateTime();
    }

    @Override
    public SysLogVO convertToVO(){
        return new SysLogVO(this);
    }


    /**
     * ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_UUID)
    private String id;

    /**
     * 用户Id
     */
    private String userId;

    /**
     * 接口的名称
     */
    private String logName;

    /**
     * 日志类型
     */
    private String logType;

    /**
     * uri
     */
    private String uri;

    /**
     * url
     */
    private String url;

    /**
     * 请求方式
     */
    private String httpMethod;

    /**
     * 请求IP
     */
    private String ip;

    /**
     * 参数
     */
    private String parameter;

    /**
     * 方法结果
     */
    private String result;

    /**
     * 请求类和方法
     */
    private String classMethod;

    /**
     * 用户代理
     */
    private String userAgent;

    /**
     * 执行花费时间
     */
    private Long takeTime;

    /**
     * 创建时间
     */
    private Date createTime;


    public enum ColName {
        id, user_id, log_name, log_type, uri, url, http_method, ip, parameter, result, class_method, user_agent, take_ime, create_time,
    }
}
